<%@ page language="java" import="java.util.*" pageEncoding="utf-8" contentType="text/html;charset=UTF-8" isELIgnored="false"%>
<%@ page import="com.example.bbs.model.User" %>
<%@ page import="com.example.bbs.model.Block" %>
<%@ page import="com.example.bbs.utils.TimeUtil" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>

<html>
<head>
	<title>帖子列表</title>	<meta charset="utf-8"/>
	<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

	<style>
		.container{
			width:1000px;
			margin:0px auto;
		}
		
		.content{
			clear:both;
		}
		
		table{
			margin:0px auto;
			border-collapse:collapse;
			margin-top:10px;
		}
		
		.right{
			float:right;
			margin-right:200px;
		}
		
	</style>
</head>

<body>
<%  if (request.getAttribute("posts") == null ) {%>
<jsp:forward page="/bbs/posts.action?bid=1" ></jsp:forward>
<%   } %>
	<div class="container">
		<jsp:include page="head.jsp" flush="true" />
		<div class="content">
			<div>
				<span>当前位置: <a href="/bbs/posts.action?bid=${block.blockId}">${block.blockName}</a></span>
				<span class="right"><a href="/pub_post.jsp?bid=${block.blockId}">发帖</a></span>
			</div>
			<table border="1px"  cellpadding="15">
				<tr>
					<th>编号</th>
					<th>帖子标题</th>
					<th>发帖人</th>
					<th>发帖时间</th>
					<th>回复数</th>
				</tr>
				<c:forEach  items="${posts}"  var="post" varStatus="status">
					<tr>
						<td>${status.count}</td>
						<td><a href="/bbs/postDetail.action?pid=${post.postId}">${post.postTitle}</a></td>
						<td>${users[status.index].userName}</td>
						<td><fmt:formatDate type="both" dateStyle="medium" timeStyle="medium" value="${post.postTime}" /></td>
						<td>${post.replyNumber}</td>
					</tr>
				</c:forEach>
			</table>
		</div>
	</div>
</body>
</html>
